package com.yufubao.framework.result;

import com.yufubao.framework.exception.BaseException;
import com.yufubao.framework.interceptor.local.LoginUserLoc;

import java.util.Objects;

import static com.yufubao.framework.enums.CommonExceptionEnum.NOT_PERMISSION;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2024/9/3 22:23
 */
public class CheckSupplier {

    /**
     * 判断当前线程商户权限
     */
    public static void checkSupplierInfo(LoginUserLoc loginUserLoc,Long supplierInfoId) {
        if (!Objects.isNull(loginUserLoc)) {
            if (!loginUserLoc.getSupplierInfoIds().contains(supplierInfoId)) {
                throw new BaseException(NOT_PERMISSION);
            }
        } else {
            throw new BaseException(NOT_PERMISSION);
        }
    }


}
